package com.hippomeetsskunk.savanna.types.goal;

import java.util.List;
import java.util.Set;

import com.hippomeetsskunk.savanna.types.meta.ResourceType;
import com.hippomeetsskunk.savanna.types.person.Person;
import com.hippomeetsskunk.savanna.types.person.Skills;
import com.hippomeetsskunk.savanna.types.resource.Field;
import com.hippomeetsskunk.savanna.types.resource.RelocatableObject;

public class TillingGoal extends AbstractGoal implements Goal {

	private final Field field;
	
	public TillingGoal(Skills requiredSkills,
			Set<ResourceType> requiredResources,
			Field field,
			Person worker) {
		super(worker, requiredSkills, requiredResources, 1.0, 1.0);
		this.field = field;
	}

	public void execute(){
		// the goal is fully determined, it needs to be able to execute
		final double work = getRequiredSkills().getSkillFactor(getWorker());
		List<RelocatableObject> resources = getWorker().getResources(getRequiredResources());
		field.till(work, resources);
	}
	
	public Field getField(){
		return field;
	}
	
	@Override
	public String toString() {
		return "Till(" + field + ")";
	}	

}
